package ch.ethz.eai.test;

import ch.ethz.eai.data.*;
import ch.ethz.eai.facade.GeocodeFacade;
import junit.framework.TestCase;

public class StoreTester extends TestCase {
	
	public void testStoreMajority(){
		StatusStore ss = new StatusStore();
		//in real programs check for the size of the array!!!
		Location banhofStr = GeocodeFacade.geocode(new Location("Banhofstrasse", "Zurich", "8088", "Switzerland"))[0];
		Location bachlerStr =  GeocodeFacade.geocode(new Location("Bachlerstrasse", "Zurich", "8046", "Switzerland"))[0];
		
		//raining in one place
		ss.save(new WeatherStatus(WeatherStatus.STAT_RAIN, banhofStr));
		ss.save(new WeatherStatus(WeatherStatus.STAT_RAIN, banhofStr));
		ss.save(new WeatherStatus(WeatherStatus.STAT_RAIN, banhofStr));
		
		//clear in other part
		ss.save(new WeatherStatus(WeatherStatus.STAT_CLOUDS, bachlerStr));
		ss.save(new WeatherStatus(WeatherStatus.STAT_CLEAR, bachlerStr));
		ss.save(new WeatherStatus(WeatherStatus.STAT_CLEAR, bachlerStr));
		
		//see how is the weather in Bachlerstrasse
		StatusResponse now = ss.majorityFor(bachlerStr, 0);
		assertTrue(now.getType()==WeatherStatus.STAT_CLEAR);
		
		//see how is the weather in the area?
		now = ss.majorityFor(bachlerStr, 1);
		assertTrue(now.getType()==WeatherStatus.STAT_RAIN);
	}
	
}
